﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SQLite;

namespace SQLiteDictionary
{
    public class SqliteKeyValuePar<TKey, TValue> : IEquatable<SqliteKeyValuePar<TKey, TValue>>
        where TKey : IEquatable<TKey>
    {
        [PrimaryKey]
        public TKey Key { get; set; }
        public TValue Value { get; set; }

        public bool Equals(SqliteKeyValuePar<TKey, TValue> Par)
        {
            return Key.Equals(Par.Key);
        }
    }

    public class SqliteKeyValueParEnumerator<TKey, TValue> : IEnumerator<SqliteKeyValuePar<TKey, TValue>>
        where TKey : IEquatable<TKey>
    {
        private List<SqliteKeyValuePar<TKey, TValue>> Items;
        private int _current = -1;

        public SqliteKeyValueParEnumerator(IEnumerable<SqliteKeyValuePar<TKey, TValue>> List)
        {
            Items = new List<SqliteKeyValuePar<TKey, TValue>>(List);
        }

        public void Reset()
        { _current = -1; }
        public bool MoveNext()
        {
            _current++;
            return _current < Items.Count;
        }

        object IEnumerator.Current
        {
            get { return Items[_current]; }
        }
        public SqliteKeyValuePar<TKey, TValue> Current
        { get { return Items[_current]; } }

        public void Dispose()
        {

        }
    }
}
